@extends('admin.layout')
@section('title','用户管理')
@section('content')
        <div class="col-md-12" id="content" >

            <div class="app_content_div" id="app_content_div_301Index">
                <h3>管理员用户列表</h3>
            </div>

            <div>
                <div style="float:right;">
                    <button type="button" class="btn btn-primary" onclick="window.location.href='/adm/user/add-user'">添加管理员用户</button>
                </div>
            </div>
            <table class="table table-striped">
                <thead>
                <tr>
                    <th>id</th>
                    <th>用户名</th>
                    <th>更改密码</th>
                    <th>删除<th>
                </tr>
                </thead>
                <tbody>
                @foreach($oUsers as $v)
                    <tr>

                        <td >{{$v->id}}</td>
                        <td >{{$v->name}}</td>
                        <td><a href="/adm/user/edit-user/{{$v->id}}" />更改密码</td>
                        <td><a onclick="delUser({{$v->id}})" ><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a></td>
                    </tr>
                @endforeach
                </tbody>
            </table>
            {{$oUsers->links('admin.page')}}
        </div>
            <script type="text/javascript" language="javascript">
                function delUser(id)
                {
                    if(id=={{Auth::user()->id}})
                    {
                        alert("不能删除当前登录用户");
                        return;
                    }
                    var r = confirm("确认删除吗？");
                    if( r == true ) {
                        var url="/adm/user/delete-user/"+id;
                        var _token="{{csrf_token()}}";
                        $.get(url,{'_token':_token},function(){
                            alert('删除成功');
                            location.reload();
                        },'json');
                    }
                }
            </script>
        </div>
@endsection
